fix: generateRequestConfirmationEvent creates events with empty ID#588
fix: generateRequestConfirmationEvent creates events with empty ID#588dannovikov wants to merge 3 commits intogoogle:mainfrom
generateRequestConfirmationEvent creates events with empty ID#588Conversation
Update functions_test.go
Summary of ChangesHello @dannovikov, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical bug in the Go ADK where events generated by Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a bug where generateRequestConfirmationEvent created events with an empty ID. The fix properly uses the session.NewEvent() factory function, which ensures a unique ID is always assigned. This change also simplifies the event creation logic by leveraging the initialization of Timestamp and StateDelta done by NewEvent(). The accompanying changes in the tests are well-written: the existing test is correctly updated to reflect the new event structure, and a new test is added to specifically verify that the generated event has a non-empty ID, preventing future regressions. The changes are solid and improve the robustness of the code.
Closes #587
Description:
generateRequestConfirmationEventininternal/llminternal/functions.goconstructs the confirmation event using a raw&session.Event{...}struct literal, which leaves theIDfield as"". In the Python ADK,Event.model_post_initauto-assigns a UUID on every construction. The Go equivalent issession.NewEvent(), which assignsuuid.NewString().The fix replaces the raw struct literal with
session.NewEvent(), which also handlesTimestampandStateDeltainitialisation — making the explicittime.Now()andActions: session.EventActions{}unnecessary.Go (
internal/llminternal/functions.go:81):Python (
src/google/adk/events/event.py:69-71):Testing:
Added
TestGenerateRequestConfirmationEventHasIDto functions_test.go which:got.ID != ""— fails before the fix, passes aftergot.InvocationID == "inv_1"for correctnessUpdated the existing
TestGenerateRequestConfirmationEventexpectedwantEventto includeStateDelta: map[string]any{}(initialised byNewEvent).